package com.juzipi.demo.config;


import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

//@Configuration
//@EnableWebSecurity// 开启WebSecurity模式
public class TestsSecurityConfig extends WebSecurityConfigurerAdapter {


    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String encode = passwordEncoder.encode("1234");

        auth.inMemoryAuthentication().withUser("xiaoming").password(encode).roles("admin");
    }


    @Bean
    PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }

    /*
    FilterSecurityInterceptor: 是一个方法级的权限过滤器，基本位于过滤器最底部
    ExceptionTranslationFilter: 是一个异常过滤器，用来处理在认证授权过程中抛出的异常
    UsernamePasswordAuthenticationFilter: 对/login的POST请求做拦截，校验表单中的用户名密码



     */
}
